﻿<?php
	include '../inc/conn.php';
	session_start();
	extract($_POST);
	extract($_GET);
	unset($_POST,$_GET);
	
	if(!isset($_SESSION['logname'])){
		die("<div>User Session is missing</div>");
	}
	
	if (isset($act))
	{
		if (empty($vContent)){
			echo "<script>alert('Some content must be filled in data!!');</script>";
			die("Some content must be filled in data!");
		}
		if ($act == 'add')
		{	
			date_default_timezone_set('Asia/Shanghai');
			$dt = date("Y-m-d H:i:s");
			$db = new mysql();
			$sql="INSERT INTO `eng_ad` (`AD_BODY`) values('".htmlspecialchars($vContent, ENT_QUOTES)."')";
			$db->query($sql);
			echo "<script>alert('Data added!');window.opener.location.reload();window.close();</script>";
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">-->
<link rel="stylesheet" href="/css/bootstrap.min.css">
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery-migrate.min.js"></script>
<script type="text/javascript" src="/xhEditor/xheditor.min.js"></script>
<script type="text/javascript" src="/xhEditor/xheditor_lang/zh-cn.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<style>
<!--
.xheDialog label {
	display: inline;
}
.form-horizontal .control-label {
	width: 80px;
}
.form-horizontal .controls {
	margin-left: 20px;
}
-->
</style>
<title>新增公告</title>
</head>
<body class="background">
<div class="container white-background pagecontent">
<form action="add_ad.php?act=add" method="post">
<div>
公告内容:<br />
<textarea name="vContent" rows="12" cols="80" class="xheditor {tools:'mfull',skin:'default', upImgUrl:'upload.php?immediate=1'}" style="width:740px;height:280px;">
</textarea>
</div>
<div><input class="btn btn-success btn-primary" name="submit" value="提交" type="submit"><input class="btn btn-danger" name="reset" value="重填" type="reset"></div>
</form>
</div>
</body>
</html>
